home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1996 July / Macworld (1996-07).dmg / For your System Folder / Sound Manager 3.2a2 / SoundInput.h < prev    next >
Text File  |  1995-11-24  |  12KB  |  287 lines

  1. /*
  2.      File:        SoundInput.h
  3.  
  4.      Contains:    Sound Input Interfaces.
  5.  
  6.      Version:    ETO
  7.  
  8.      DRI:        Jim Reekes
  9.  
  10.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  11.                  All rights reserved.
  12.  
  13.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  14.                  stack.  Include the file and version information (from above)
  15.                  in the problem description and send to:
  16.                      Internet:    apple.bugs@applelink.apple.com
  17.                      AppleLink:    APPLE.BUGS
  18.  
  19. */
  20.  
  21. #ifndef __SOUNDINPUT__
  22. #define __SOUNDINPUT__
  23.  
  24.  
  25. #ifndef __TYPES__
  26. #include <Types.h>
  27. #endif
  28. /*    #include <ConditionalMacros.h>                                */
  29.  
  30. #ifndef __APPLEEVENTS__
  31. #include <AppleEvents.h>
  32. #endif
  33. /*    #include <Errors.h>                                            */
  34. /*    #include <Memory.h>                                            */
  35. /*        #include <MixedMode.h>                                    */
  36. /*    #include <OSUtils.h>                                        */
  37. /*    #include <Events.h>                                            */
  38. /*        #include <Quickdraw.h>                                    */
  39. /*            #include <QuickdrawText.h>                            */
  40. /*    #include <EPPC.h>                                            */
  41. /*        #include <AppleTalk.h>                                    */
  42. /*        #include <Files.h>                                        */
  43. /*            #include <Finder.h>                                    */
  44. /*        #include <PPCToolbox.h>                                    */
  45. /*        #include <Processes.h>                                    */
  46. /*    #include <Notification.h>                                    */
  47.  
  48. #ifndef __WINDOWS__
  49. #include <Windows.h>
  50. #endif
  51. /*    #include <Controls.h>                                        */
  52. /*        #include <Menus.h>                                        */
  53.  
  54. #ifndef __DIALOGS__
  55. #include <Dialogs.h>
  56. #endif
  57. /*    #include <TextEdit.h>                                        */
  58.  
  59. #ifndef __FILES__
  60. #include <Files.h>
  61. #endif
  62.  
  63. #ifndef __SOUND__
  64. #include <Sound.h>
  65. #endif
  66. /*    #include <Components.h>                                        */
  67.  
  68. #ifdef __cplusplus
  69. extern "C" {
  70. #endif
  71.  
  72. #if PRAGMA_ALIGN_SUPPORTED
  73. #pragma options align=mac68k
  74. #endif
  75.  
  76. #if PRAGMA_IMPORT_SUPPORTED
  77. #pragma import on
  78. #endif
  79.  
  80. /*
  81.                         * * *  N O T E  * * *
  82.  
  83.     This file has been updated to include Sound Input Manager 1.1 interfaces.
  84.  
  85.     Some of the Sound Input Manager 1.1 interfaces were not put into the InterfaceLib
  86.     that originally shipped with the PowerMacs. These missing functions and the
  87.     new 1.1 interfaces have been released in the SoundLib library for PowerPC
  88.     developers to link with. The runtime library for these functions are
  89.     installed by Sound Manager 3.2. The following functions are found in SoundLib.
  90.  
  91.         ParseAIFFHeader(), ParseSndHeader()
  92.  
  93. */
  94.  
  95. enum {
  96.     siDeviceIsConnected            = 1,                            /*input device is connected and ready for input*/
  97.     siDeviceNotConnected        = 0,                            /*input device is not connected*/
  98.     siDontKnowIfConnected        = -1,                            /*can't tell if input device is connected*/
  99.     siReadPermission            = 0,                            /*permission passed to SPBOpenDevice*/
  100.     siWritePermission            = 1                                /*permission passed to SPBOpenDevice*/
  101. };
  102.  
  103. enum {
  104. /*Info Selectors for Sound Input Drivers*/
  105.     siActiveChannels            = 'chac',                        /*active channels*/
  106.     siActiveLevels                = 'lmac',                        /*active meter levels*/
  107.     siAGCOnOff                    = 'agc ',                        /*automatic gain control state*/
  108.     siAsync                        = 'asyn',                        /*asynchronous capability*/
  109.     siChannelAvailable            = 'chav',                        /*number of channels available*/
  110.     siCompressionAvailable        = 'cmav',                        /*compression types available*/
  111.     siCompressionFactor            = 'cmfa',                        /*current compression factor*/
  112.     siCompressionHeader            = 'cmhd',                        /*return compression header*/
  113.     siCompressionNames            = 'cnam',                        /*compression type names available*/
  114.     siCompressionType            = 'comp',                        /*current compression type*/
  115.     siContinuous                = 'cont',                        /*continous recording*/
  116.     siDeviceBufferInfo            = 'dbin',                        /*size of interrupt buffer*/
  117.     siDeviceConnected            = 'dcon',                        /*input device connection status*/
  118.     siDeviceIcon                = 'icon',                        /*input device icon*/
  119.     siDeviceName                = 'name',                        /*input device name*/
  120.     siHardwareBusy                = 'hwbs',                        /*sound hardware is in use*/
  121.     siInputGain                    = 'gain',                        /*input gain*/
  122.     siInputSource                = 'sour',                        /*input source selector*/
  123.     siInputSourceNames            = 'snam',                        /*input source names*/
  124.     siLevelMeterOnOff            = 'lmet',                        /*level meter state*/
  125.     siModemGain                    = 'mgai',                        /*modem input gain*/
  126.     siNumberChannels            = 'chan',                        /*current number of channels*/
  127.     siOptionsDialog                = 'optd',                        /*display options dialog*/
  128.     siPlayThruOnOff                = 'plth',                        /*playthrough state*/
  129.     siRecordingQuality            = 'qual',                        /*recording quality*/
  130.     siSampleRate                = 'srat',                        /*current sample rate*/
  131.     siSampleRateAvailable        = 'srav',                        /*sample rates available*/
  132.     siSampleSize                = 'ssiz',                        /*current sample size*/
  133.     siSampleSizeAvailable        = 'ssav',                        /*sample sizes available*/
  134.     siSetupCDAudio                = 'sucd',                        /*setup sound hardware for CD audio*/
  135.     siSetupModemAudio            = 'sumd',                        /*setup sound hardware for modem audio*/
  136.     siStereoInputGain            = 'sgai',                        /*stereo input gain*/
  137.     siTwosComplementOnOff        = 'twos',                        /*two's complement state*/
  138.     siVoxRecordInfo                = 'voxr',                        /*VOX record parameters*/
  139.     siVoxStopInfo                = 'voxs',                        /*VOX stop parameters*/
  140.     siCloseDriver                = 'clos',                        /*reserved for internal use only*/
  141.     siInitializeDriver            = 'init',                        /*reserved for internal use only*/
  142.     siPauseRecording            = 'paus',                        /*reserved for internal use only*/
  143.     siUserInterruptProc            = 'user',                        /*reserved for internal use only*/
  144. /*Qualities*/
  145.     siCDQuality                    = 'cd  ',                        /*44.1kHz, stereo, 16 bit*/
  146.     siBestQuality                = 'best',                        /*22kHz, mono, 8 bit*/
  147.     siBetterQuality                = 'betr',                        /*22kHz, mono, MACE 3:1*/
  148.     siGoodQuality                = 'good'
  149. };
  150.  
  151. typedef struct SPB SPB, *SPBPtr;
  152.  
  153. /*user procedures called by sound input routines*/
  154. /*
  155.         SIInterruptProcPtr uses register based parameters on the 68k and cannot
  156.         be written in or called from a high-level language without the help of
  157.         mixed mode or assembly glue.
  158.  
  159.             typedef pascal void (*SIInterruptProcPtr)(SPBPtr inParamPtr, Ptr dataBuffer, short peakAmplitude, long sampleSize);
  160.  
  161.         In:
  162.          => inParamPtr      A0.L
  163.          => dataBuffer      A1.L
  164.          => peakAmplitude    D0.W
  165.          => sampleSize      D1.L
  166. */
  167. typedef pascal void (*SICompletionProcPtr)(SPBPtr inParamPtr);
  168.  
  169. #if GENERATINGCFM
  170. typedef UniversalProcPtr SIInterruptUPP;
  171. typedef UniversalProcPtr SICompletionUPP;
  172. #else
  173. typedef Register68kProcPtr SIInterruptUPP;
  174. typedef SICompletionProcPtr SICompletionUPP;
  175. #endif
  176.  
  177. struct SPB {
  178.     long                            inRefNum;                    /*reference number of sound input device*/
  179.     unsigned long                    count;                        /*number of bytes to record*/
  180.     unsigned long                    milliseconds;                /*number of milliseconds to record*/
  181.     unsigned long                    bufferLength;                /*length of buffer in bytes*/
  182.     Ptr                                bufferPtr;                    /*buffer to store sound data in*/
  183.     SICompletionUPP                    completionRoutine;            /*completion routine*/
  184.     SIInterruptUPP                    interruptRoutine;            /*interrupt routine*/
  185.     long                            userLong;                    /*user-defined field*/
  186.     OSErr                            error;                        /*error*/
  187.     long                            unused1;                    /*reserved - must be zero*/
  188. };
  189.  
  190.  
  191. extern pascal NumVersion SPBVersion(void)
  192.  FOURWORDINLINE(0x203C, 0x0000, 0x0014, 0xA800);
  193. extern pascal OSErr SndRecord(ModalFilterUPP filterProc, Point corner, OSType quality, SndListHandle *sndHandle)
  194.  FOURWORDINLINE(0x203C, 0x0804, 0x0014, 0xA800);
  195. extern pascal OSErr SndRecordToFile(ModalFilterUPP filterProc, Point corner, OSType quality, short fRefNum)
  196.  FOURWORDINLINE(0x203C, 0x0708, 0x0014, 0xA800);
  197. extern pascal OSErr SPBSignInDevice(short deviceRefNum, ConstStr255Param deviceName)
  198.  FOURWORDINLINE(0x203C, 0x030C, 0x0014, 0xA800);
  199. extern pascal OSErr SPBSignOutDevice(short deviceRefNum)
  200.  FOURWORDINLINE(0x203C, 0x0110, 0x0014, 0xA800);
  201. extern pascal OSErr SPBGetIndexedDevice(short count, Str255 deviceName, Handle *deviceIconHandle)
  202.  FOURWORDINLINE(0x203C, 0x0514, 0x0014, 0xA800);
  203. extern pascal OSErr SPBOpenDevice(ConstStr255Param deviceName, short permission, long *inRefNum)
  204.  FOURWORDINLINE(0x203C, 0x0518, 0x0014, 0xA800);
  205. extern pascal OSErr SPBCloseDevice(long inRefNum)
  206.  FOURWORDINLINE(0x203C, 0x021C, 0x0014, 0xA800);
  207. extern pascal OSErr SPBRecord(SPBPtr inParamPtr, Boolean asynchFlag)
  208.  FOURWORDINLINE(0x203C, 0x0320, 0x0014, 0xA800);
  209. extern pascal OSErr SPBRecordToFile(short fRefNum, SPBPtr inParamPtr, Boolean asynchFlag)
  210.  FOURWORDINLINE(0x203C, 0x0424, 0x0014, 0xA800);
  211. extern pascal OSErr SPBPauseRecording(long inRefNum)
  212.  FOURWORDINLINE(0x203C, 0x0228, 0x0014, 0xA800);
  213. extern pascal OSErr SPBResumeRecording(long inRefNum)
  214.  FOURWORDINLINE(0x203C, 0x022C, 0x0014, 0xA800);
  215. extern pascal OSErr SPBStopRecording(long inRefNum)
  216.  FOURWORDINLINE(0x203C, 0x0230, 0x0014, 0xA800);
  217. extern pascal OSErr SPBGetRecordingStatus(long inRefNum, short *recordingStatus, short *meterLevel, unsigned long *totalSamplesToRecord, unsigned long *numberOfSamplesRecorded, unsigned long *totalMsecsToRecord, unsigned long *numberOfMsecsRecorded)
  218.  FOURWORDINLINE(0x203C, 0x0E34, 0x0014, 0xA800);
  219. extern pascal OSErr SPBGetDeviceInfo(long inRefNum, OSType infoType, void *infoData)
  220.  FOURWORDINLINE(0x203C, 0x0638, 0x0014, 0xA800);
  221. extern pascal OSErr SPBSetDeviceInfo(long inRefNum, OSType infoType, void *infoData)
  222.  FOURWORDINLINE(0x203C, 0x063C, 0x0014, 0xA800);
  223. extern pascal OSErr SPBMillisecondsToBytes(long inRefNum, long *milliseconds)
  224.  FOURWORDINLINE(0x203C, 0x0440, 0x0014, 0xA800);
  225. extern pascal OSErr SPBBytesToMilliseconds(long inRefNum, long *byteCount)
  226.  FOURWORDINLINE(0x203C, 0x0444, 0x0014, 0xA800);
  227. extern pascal OSErr SetupSndHeader(SndListHandle sndHandle, short numChannels, UnsignedFixed sampleRate, short sampleSize, OSType compressionType, short baseNote, unsigned long numBytes, short *headerLen)
  228.  FOURWORDINLINE(0x203C, 0x0D48, 0x0014, 0xA800);
  229. extern pascal OSErr SetupAIFFHeader(short fRefNum, short numChannels, UnsignedFixed sampleRate, short sampleSize, OSType compressionType, unsigned long numBytes, unsigned long numFrames)
  230.  FOURWORDINLINE(0x203C, 0x0B4C, 0x0014, 0xA800);
  231.  
  232.  
  233. /* Sound Input Manager 1.1 and later calls */
  234. extern pascal OSErr ParseAIFFHeader(short fRefNum, SoundComponentData *sndInfo, unsigned long *numFrames, unsigned long *dataOffset)
  235.  FOURWORDINLINE(0x203C, 0x0758, 0x0014, 0xA800);
  236. extern pascal OSErr ParseSndHeader(SndListHandle sndHandle, SoundComponentData *sndInfo, unsigned long *numFrames, unsigned long *dataOffset)
  237.  FOURWORDINLINE(0x203C, 0x085C, 0x0014, 0xA800);
  238.  
  239.  
  240. enum {
  241.     uppSIInterruptProcInfo = kRegisterBased
  242.          | REGISTER_ROUTINE_PARAMETER(1, kRegisterA0, SIZE_CODE(sizeof(SPBPtr)))
  243.          | REGISTER_ROUTINE_PARAMETER(2, kRegisterA1, SIZE_CODE(sizeof(Ptr)))
  244.          | REGISTER_ROUTINE_PARAMETER(3, kRegisterD0, SIZE_CODE(sizeof(short)))
  245.          | REGISTER_ROUTINE_PARAMETER(4, kRegisterD1, SIZE_CODE(sizeof(long))),
  246.     uppSICompletionProcInfo = kPascalStackBased
  247.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(SPBPtr)))
  248. };
  249.  
  250. #if GENERATINGCFM
  251. #define NewSIInterruptProc(userRoutine)        \
  252.         (SIInterruptUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppSIInterruptProcInfo, GetCurrentArchitecture())
  253. #define NewSICompletionProc(userRoutine)        \
  254.         (SICompletionUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppSICompletionProcInfo, GetCurrentArchitecture())
  255. #else
  256. #define NewSIInterruptProc(userRoutine)        \
  257.         ((SIInterruptUPP) (userRoutine))
  258. #define NewSICompletionProc(userRoutine)        \
  259.         ((SICompletionUPP) (userRoutine))
  260. #endif
  261.  
  262. #if GENERATINGCFM
  263. #define CallSIInterruptProc(userRoutine, inParamPtr, dataBuffer, peakAmplitude, sampleSize)        \
  264.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppSIInterruptProcInfo, (inParamPtr), (dataBuffer), (peakAmplitude), (sampleSize))
  265. #define CallSICompletionProc(userRoutine, inParamPtr)        \
  266.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppSICompletionProcInfo, (inParamPtr))
  267. #else
  268. /* (*SIInterruptProcPtr) cannot be called from a high-level language without the Mixed Mode Manager */
  269. #define CallSICompletionProc(userRoutine, inParamPtr)        \
  270.         (*(userRoutine))((inParamPtr))
  271. #endif
  272.  
  273.  
  274. #if PRAGMA_IMPORT_SUPPORTED
  275. #pragma import off
  276. #endif
  277.  
  278. #if PRAGMA_ALIGN_SUPPORTED
  279. #pragma options align=reset
  280. #endif
  281.  
  282. #ifdef __cplusplus
  283. }
  284. #endif
  285.  
  286. #endif /* __SOUNDINPUT__ */
  287.